package yzbx.personalwebsite.entityWeb;

import lombok.Data;

import static yzbx.personalwebsite.config.Constants.*;

/**
 * {@code @Author} zxm
 * {@code @Description} Http返回包装类
 * {@code @Date} 2024/10/08/15:35
 * {@code @Version} 1.0
 */
@Data
public class HttpResponse {

    public HttpResponse(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    private String code;
    private String msg;
    private Object data;

    public static HttpResponse success() {
        return new HttpResponse(HTTP_CODE_200, HTTP_CODE_200_MSG, null);
    }

    public static HttpResponse success(Object data) {
        return new HttpResponse(HTTP_CODE_200, HTTP_CODE_200_MSG, data);
    }

    public static HttpResponse fail() {
        return new HttpResponse(HTTP_CODE_500, HTTP_CODE_500_MSG, null);
    }

    public static HttpResponse fail(String msg) {
        return new HttpResponse(HTTP_CODE_500, msg, null);
    }
}
